<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //声明两个promise对象
        const p1 = new Promise((resolve, reject) => {
            setTimeout(() => {
                resolve('商品数据-1');
            }, 1000);
        })
        const p2 = new Promise((resolve, reject) => {
            setTimeout(() => {
                // resolve('商品数据-2');
                reject('出错了！');
            }, 1000);
        })
        //调用allsettled方法,无论咋样都显示成功，会把每一个状态都显示出来
        const result = Promise.allSettled([p1, p2]);
        //all方法，必须要每一个都显示成功才行
        const res = Promise.all([p1, p2]);
        console.log(res);
        console.log(result);






    </script>
</body>

</html>